package me.zhengjie.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.Log;
import me.zhengjie.dao.OutboundOrder;
import me.zhengjie.server.SortingService;
import me.zhengjie.utils.Result;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequiredArgsConstructor
@Api(tags = "分拣管理")
@RequestMapping("/api/sorting")
public class SortingController {

    private final SortingService sortingService;

    @Log("分拣结束")
    @ApiOperation("分拣结束")
    @GetMapping("/finish")
    public Result finishSorting(String outboundCode,String containerIdO, String containerIdT) throws IOException {
        return Result.ok(sortingService.finishSorting(outboundCode,containerIdO, containerIdT));
    }

    @Log("分拣配送叫车")
    @ApiOperation("分拣配送叫车")
    @GetMapping("/sortingToWcs")
    public Result sortingToWcs(String outBoundOrderCode){
        String s = sortingService.sortingToWcs(outBoundOrderCode);
        if (s.equals("sucess")){
            return Result.ok(s);
        }else {
            return Result.fail(s);
        }
    }
}
